<template>
  <div class="orderList">
    <div class="orderList__title">{{ shopName }}</div>
    <div class="right">
      <template v-for="(item, key) in dataList" :key="key">
        <div class="right__item" v-if="item.count > 0">
          <div class="item__img">
            <img class="img" :src="item.imgUrl" alt="" />
          </div>
          <div class="item__txt">
            <p class="item__title">{{ item.name }}</p>
            <p class="item__price">
              <span class="normalPrice"
                >&yen;{{ item.price }} x{{ item.count }}</span
              >
            </p>
          </div>
          <div class="item__total">
            &yen;{{ (item.price * item.count).toFixed(2) }}
          </div>
        </div>
      </template>
    </div>
    <div class="orderList__sum">共计{{ result.totalCount }}件/{{ 1.4 }}kg</div>
  </div>
</template>

<script>
import { useRoute } from "vue-router";
import { useCommonCartEffect } from "@/effects/cartEffect.js";
export default {
  name: "ProductList",
  setup() {
    const route = useRoute();
    const shopId = route.params.id;
    const { shopName, dataList, result } = useCommonCartEffect(shopId);
    return { shopName, dataList, result };
  },
};
</script>

<style lang="scss" scoped>
@import "@/styles/variables.scss";
.orderList {
  box-sizing: border-box;
  height: 3.9rem;
  margin-top: 0.16rem;
  background-color: #fff;
  border-radius: 0.04rem;
  &__title {
    box-sizing: border-box;
    padding-left: 0.16rem;
    color: $content-color;
    font-weight: 600;
    font-size: 0.16rem;
    line-height: 0.5rem;
    margin-top: 0.16rem;
  }
  &__sum {
    z-index: 99;
    margin-top: 0.16rem;
    margin-left: 0.16rem;
    margin-right: 0.16rem;
    width: 3.07rem;
    height: 0.28rem;
    line-height: 0.28rem;
    text-align: center;
    background-color: #f5f5f5;
    font-size: 0.14rem;
    color: #999999;
  }
}

.right {
  overflow-y: scroll;
  width: 100%;
  background: #fff;
  &__item {
    height: 0.7rem;
    position: relative;
    box-sizing: border-box;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.16rem 0 0.18rem;
    .item__img {
      display: flex;
      justify-content: center;
      align-items: center;
      .img {
        height: 0.46rem;
        width: 0.46rem;
      }
    }
    .item__txt {
      margin-top: 0.15rem;
      margin-right: 0.5rem;
      height: 0.69rem;
      width: 50%;
      .item__title {
        line-height: 0.3rem;
        font-size: 0.14rem;
        color: $content-color;
      }
      .item__price {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        line-height: 0.25rem;
        color: $highlight-color;
      }
    }
    .btn {
      margin-right: 0.18rem;
    }
  }
}
</style>
